package org.gzc.controller;

import org.gzc.model.NoticeDetailData;
import org.gzc.pojo.Notice;
import org.gzc.service.NoticeService;
import org.gzc.service.UserService;
import org.gzc.util.PagingResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public PagingResultUtil<NoticeDetailData> getNoticeList(Notice notice, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit) {
        List<Notice> notices = noticeService.queryNoticesByPaging(notice, page, limit);
        int total = noticeService.getTotal();
        return PagingResultUtil.success.setCurrPage(page).setLimit(limit).setCount(total).setData(notices);
    }

    
}
